package com.onepower.admin.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.onepower.core.modules.repository.entity.MatchProject;
import com.onepower.core.modules.service.IMatchProjectService;
import com.onepower.core.result.CommonResult;
import com.onepower.core.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author kin
 * @since 2018-08-24
 */
@RestController
@RequestMapping("api/match/project")
public class MatchProjectController {

    @Autowired
    private IMatchProjectService matchProjectService;

    @RequestMapping(value = "list", method = RequestMethod.GET)
    public CommonResult list(@RequestParam(value = "matchId", required = false, defaultValue = "0") int matchId) {
        List<MatchProject> matchProjectList = matchProjectService.list(new LambdaQueryWrapper<MatchProject>()
                .eq(MatchProject::getMatchId, matchId)
        );
        return ResultUtils.ok(matchProjectList);
    }


    @RequestMapping(value = "delete", method = RequestMethod.POST)
    public CommonResult delete(@RequestBody Integer[] projectIds) {
        matchProjectService.removeByIds(Arrays.asList(projectIds));
        return ResultUtils.ok();
    }
}
